package de.baumann.browser.model;

import de.baumann.browser.api.net.util.UserHttpUtil;
import de.baumann.browser.api.net.vo.LoginInfo;
import de.baumann.browser.api.net.vo.QiNiuToken;
import de.baumann.browser.api.net.vo.Result;
import de.baumann.browser.rx.RxSchedulers;
import de.baumann.browser.utils.UserDataKt;
import io.reactivex.Observable;

public class BaseModel {
    protected static final long TIMEDIFFERENCE = 1000 * 60 * 60;

    protected String getToken() {
        LoginInfo loginInfo = UserDataKt.getUser();
        if (loginInfo != null) {
            return loginInfo.getToken();
        }
        return "";
    }

    protected String getUserId() {
        LoginInfo loginInfo = UserDataKt.getUser();
        if (loginInfo != null) {
            return String.valueOf(loginInfo.getUser_id());
        }
        return "";
    }

    public Observable<Result<QiNiuToken>> getQiNiuToken() {
        return UserHttpUtil.getQiNiuToken().compose(RxSchedulers.ioMain());
    }

}
